package com.example.ylgh.controller;

import com.example.result.Result;
import com.example.ylgh.model.hosp.Hospital;
import com.example.ylgh.service.HospitalService;
import com.example.ylgh.service.HospitalSetService;
import com.example.ylgh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author hx
 * @create 2022/5/12 10:04
 * description:
 */
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    /**
     * 医院详情接口
     * @param id
     * @return
     */
    @GetMapping("/showHospDetails/{id}")
    public Result showHospDetails(@PathVariable String id){
        Map<String, Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }

    //更新医院上线状态
    @PutMapping ("updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable String id, @PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();

    }

    @GetMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer limit,
                           @PathVariable Integer page,
                           HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel =hospitalService.selectHosp(limit,page,hospitalQueryVo);
        return Result.ok(pageModel);
    }
}
